import request from '@/utils/request'

const api_name = '/admin/acl/project'

export default {

  //根据用户获取项目数据
  getProjectList(name) {
    return request({
      url: `${api_name}/getProjectList`,
      method: 'get',
      params:name
    })
  },
  //删除项目
  projectRemove(id){
    return request({
      url: `${api_name}/projectRemove/${id}`,
      method: 'post',
    })
  },
  //添加项目
  projectSave(project){
    return request({
      url: `${api_name}/projectSave`,
      method: 'post',
      data:project
    })
  },
  //修改
  projectUpdate(data){
    return request({
      url: `${api_name}/projectUpdate`,
      method: 'post',
      data:data
    })
  },
  //根据项目id获取项目信息
  selectProject(id){
    return request({
      url: `${api_name}/selectProject/${id}`,
      method: 'post'
    })
  },
  getById(id) {
    return request({
      url: `${api_name}/get/${id}`,
      method: 'get'
    })
  },
  save(user) {
    return request({
      url: `${api_name}/save`,
      method: 'post',
      data: user
    })
  },

  updateById(user) {
    return request({
      url: `${api_name}/update`,
      method: 'put',
      data: user
    })
  },
  getAssign(userId){
    return request({
      url: `${api_name}/toAssign/${userId}`,
      method: 'get'
    })
  },
  saveAssign(userId, roleId){
    return request({
      url: `${api_name}/doAssign`,
      method: 'post',
      params:{userId, roleId}
    })
  },
  removeById(id){
    return request({
      url: `${api_name}/remove/${id}`,
      method: 'delete'
    })
  },
  removeRows(idList){
    return request({
      url: `${api_name}/batchRemove`,
      method: 'delete',
      data:idList
    })
  },
  distributeEventToRole(data,roleId) {
    return request({
      url: `/admin/acl/role/distributeEventToRole/${roleId}`,
      method: 'POST',
      data,
    })
  },
  getProjectIdsByRole(roleId) {
    return request ({
      url: `${api_name}/getProjectIdsByRole/${roleId}`,
      method: 'get'
    })
  },
  getMyProjectIds(roleId){
    return request({
      url: `/admin/acl/project/getProjectIdsByRole/${roleId}`,
      method: 'get',
    })
  }
}
